<?php

echo '<hr><a name="current"><h1>Current Load:</h1></a>' . "\n";
foreach ($total as $team => $value) {
    echo '<li>' . $team . '</li>';
    echo '<table><tr> 
          <td><b>TSE</b></td>
          <td width=40 title="Tital Opened"><b>Total</b></td>
          <td width=40 title="Open Tier 2"><b>T2</b></td>
          <td width=40 title="Open Tier 3"><b>T3</b></td>
          <td width=40 title="Engineering Request"><b>ER</b></td>
          <td width=40 title="Solution Proposed"><b>SP</b></td>
          <td width=40 title="Info Required From Customer"><b>AI</b></td>
          <td width=40 title="PM Review"><b>PM</b></td>
          <td width=40 title="Third Party Pending"><b>3rd</b></td>
          </tr>' . "\n";
    foreach ($total[$team] as $key => $value) {
        echo '<tr><td><a href="#' . $key . '"> ' . $key . '</td><td>';
        echo $total[$team][$key]['srs_t'] . '</td><td>';
        $total[$team]['srs_o']+=$total[$team][$key]['srs_t'];
        echo $total[$team][$key]['Tier 2']['substatus_t'] + $total[$team][$key]['New']['substatus_t'] + $total[$team][$key]['Tier 1']['substatus_t'] . '</td><td>';
        $total[$team]['srs_t2']+=($total[$team][$key]['Tier 2']['substatus_t'] + $total[$team][$key]['New']['substatus_t'] + $total[$team][$key]['Tier 1']['substatus_t']);
        echo $total[$team][$key]['Tier 3']['substatus_t'] . '</td><td>';
        $total[$team]['srs_t3']+=$total[$team][$key]['Tier 3']['substatus_t'];
        echo $total[$team][$key]['Engineering Request']['substatus_t'] . '</td><td>';
        $total[$team]['srs_er']+=$total[$team][$key]['Engineering Request']['substatus_t'];
        echo $total[$team][$key]['Replied']['substatus_t'] + $total[$team][$key]['Fixed-Software Provided']['substatus_t'] + $total[$team][$key]['Order Pending']['substatus_t'] . '</td><td>';
        $total[$team]['srs_sp']+=($total[$team][$key]['Replied']['substatus_t'] + $total[$team][$key]['Fixed-Software Provided']['substatus_t'] + $total[$team][$key]['Order Pending']['substatus_t']);
        echo $total[$team][$key]['Info Required From Customer']['substatus_t'] . '</td><td>';
        $total[$team]['srs_ai']+=$total[$team][$key]['Info Required From Customer']['substatus_t'];
        echo $total[$team][$key]['PM Review']['substatus_t'] . '</td><td>';
        $total[$team]['srs_pm']+=$total[$team][$key]['PM Review']['substatus_t'];
        echo $total[$team][$key]['Third Party Pending']['substatus_t'] . '</td></tr>' . "\n";
        $total[$team]['srs_3d']+=$total[$team][$key]['Third Party Pending']['substatus_t'];
    }
    echo '<tr> 
          <td><b>TOTAL</b></td>
          <td><b>' . $total[$team]['srs_o'] . '</b></td>
          <td><b>' . $total[$team]['srs_t2'] . '</b></td>
          <td><b>' . $total[$team]['srs_t3'] . '</b></td>
          <td><b>' . $total[$team]['srs_er'] . '</b></td>
          <td><b>' . $total[$team]['srs_sp'] . '</b></td>
          <td><b>' . $total[$team]['srs_ai'] . '</b></td>
          <td><b>' . $total[$team]['srs_pm'] . '</b></td>
          <td><b>' . $total[$team]['srs_3d'] . '</b></td>
          </tr>' . "\n";

    echo '</table>' . "\n";
}

foreach ($current as $team => $value) {
    echo '<li>' . $team . '</li>';
    echo '<table><tr><td>Name (SRs)</td>
        <td width=60>Status</td>
        <td width=80>Priority</td>
        <td width=60>SR #</td>
        <td width=60>Opened</td>
        <td width=80>Modified</td>
        <td width=60>Last public</td>
        <td width=30>Down</td>        
        <td width=30>Escltn</td>
        <td width=90>Product</td>
        <td width=60>Region</td>
        </tr>' . "\n";

    foreach ($current[$team] as $key => $value) {
        // Name
        echo '<tr><td rowspan=' . $total[$team][$key]['srs_t'] . ' title="' . $key . '">';
        echo '<a name="' . $key . '">' . $key . '</a> (' . $total[$team][$key]['srs_t'] . ')';
        echo '</td>';
        foreach ($current[$team][$key] as $key1 => $value) {
            // Status
            echo '<td rowspan=' . $total[$team][$key][$key1]['substatus_t'] . ' title="' . $key1 . '">';
            echo $key1;
            echo '</td>';
            foreach ($current[$team][$key][$key1] as $key2 => $value) {
                //Priority
                echo '<td rowspan=' . $total[$team][$key][$key1][$key2]['priority_t'] . ' title="Priority">';
                echo $key2 . '</td>';
                foreach ($current[$team][$key][$key1][$key2] as $key3 => $value) {
                    echo '<td title="SR #">' . $key3 . '</td>';
                    echo '<td title="Date opened">' . $current[$team][$key][$key1][$key2][$key3]['opened'] . '</td>';
                    echo '<td title="Modified date">' . $current[$team][$key][$key1][$key2][$key3]['modified'] . '</td>';
                    echo '<td title="Last public update">' . $current[$team][$key][$key1][$key2][$key3]['lastpublic'] . '</td>';
                    if ($current[$team][$key][$key1][$key2][$key3]['pdown'] == 'N')
                        $current[$team][$key][$key1][$key2][$key3]['pdown'] = '';
                    echo '<td title="Production Down">' . $current[$team][$key][$key1][$key2][$key3]['pdown'] . '</td>';
                    if ($current[$team][$key][$key1][$key2][$key3]['escalated'] == 'N')
                        $current[$team][$key][$key1][$key2][$key3]['escalated'] = '';
                    echo '<td title="Escalated">' . $current[$team][$key][$key1][$key2][$key3]['escalated'] . '</td>';
                    echo '<td title="Product">' . $current[$team][$key][$key1][$key2][$key3]['product'] . '</td>';
                    echo '<td title="Region">' . $current[$team][$key][$key1][$key2][$key3]['custregion'] . '</td>';
                    echo '</tr>' . "\n";
                }
            }
        }
    }
    echo '</table>' . "\n";
    echo '<a href="#top">top</a><br>' . "\n";
}
/* echo '<td title="days w/o update">' . $cur[$key][$key1][$key2][$key3]['Overdue'] . '</td>';
  echo '<td title="Tier-3 owner">' . $cur[$key][$key1][$key2][$key3]['T3'] . '</td>';
  echo '<td title="Product">' . $cur[$key][$key1][$key2][$key3]['Product'] . '</td>';
  echo '<td title="Escalation flag">';
  if ($cur[$key][$key1][$key2][$key3]['Eacalated'] == 'Y')
  echo '<img src="img\escalated.gif">'; echo '</td>';
  echo '<td title="Training flag">';
  if ($cur[$key][$key1][$key2][$key3]['OnTrain'] == 'Y')
  echo '<img src="img\natanke.gif">'; echo '</td>';
  echo '<td title="Production down"';
  if ($cur[$key][$key1][$key2][$key3]['Down'] == 'Y') {
  echo ' class="red">Y';
  } else
  echo '>'; echo '</td>';
  echo '<td title="End User Support Group">';
  if ($cur[$key][$key1][$key2][$key3]['Region'] <> 'EMEA')
  echo $cur[$key][$key1][$key2][$key3]['SG']; echo'</td>';
 */
?>


